import http from '../../http'
import type { ApiResponse } from '@/types/api'

export async function login(username: string, password: string) {
  const resp = await http.post<ApiResponse<{ token: string }>>('/auth/login', { username, password })
  return resp.data
}

export async function logout() {
  const resp = await http.post<ApiResponse<boolean>>('/auth/logout')
  return resp.data
}

export interface UserProfileVO {
  id: number
  username: string
  nickname?: string
  avatar?: string
  email?: string
  roles?: string
  perms?: string
}

export async function getProfile() {
  const resp = await http.get<ApiResponse<UserProfileVO>>('/auth/profile')
  return resp.data
}


